package top.mengchaob;

import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @title：
 * @author: mengchaob
 * @date: 2021年06月03日 15:14
 * @description:
 */
public class TestMain {

    public interface TT{
        void aa();
    }

   public static class AAtt {
       public static void aa() {
           System.out.println("AAtt aa");
       }
   }

   public void testAa(TT tt){
        tt.aa();
   }

    public static void main(String[] args) {
//        File file = new File("D:\\gitWorkSpace\\output\\dev-test\\WebSSH.jar");
//        String rootPath = file.getParent();
//        File newFile = new File("E:\\AAS-V9.0\\domains\\rds_sj_before\\"+33333);
//        file.renameTo(newFile);
//        Integer tem = Integer.valueOf("1" + "10006001011") + 1;// 以0开头,
//        System.out.println(TestMain.underline2Camel("AA_BB",true));
        TestMain t = new TestMain();
        t.testAa(()->{
            System.out.println("AA AA");
        });
    }

    /**
     * 下划线转驼峰法
     * @param line 源字符串
     * @param smallCamel 大小驼峰,是否为小驼峰
     * @return 转换后的字符串
     */
    public static String underline2Camel(String line,boolean smallCamel){
        if(line==null||"".equals(line)){
            return "";
        }
        StringBuffer sb=new StringBuffer();
        Pattern pattern=Pattern.compile("([A-Za-z\\d]+)(_)?");
        Matcher matcher=pattern.matcher(line);
        while(matcher.find()){
            String word=matcher.group();
            sb.append(smallCamel&&matcher.start()==0?Character.toLowerCase(word.charAt(0)):Character.toUpperCase(word.charAt(0)));
            int index=word.lastIndexOf('_');
            if(index>0){
                sb.append(word.substring(1, index).toLowerCase());
            }else{
                sb.append(word.substring(1).toLowerCase());
            }
        }
        return sb.toString();
    }


}
